package com.ieheima.zuoye2;

import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.time.temporal.ChronoUnit;

public class Test {
    public static void main(String[] args) {

        LocalDateTime now = LocalDateTime.now();
        DateTimeFormatter dtf = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
        String format = dtf.format(now);
        System.out.println(format);
        String  time = "2026-02-17 00:00:00";
        LocalDateTime parse = LocalDateTime.parse(time, dtf);

        //计算现在到2025-01-22 00:00:00的间隔天数
        long between = ChronoUnit.SECONDS.between(now, parse);
        long days = between / (24*60*60);
        long hous = between % (24*60*60)/(60*60);
        long min = between % (24*60*60)%(60*60)/60;
        long s = between % 60;
        System.out.println("天数"+days+","+hous+"小时"+min+"分钟"+s+"秒");

    }
}
